import Mock from "mockjs";

const methodP=["支付宝","微信支付","银行转账"];
const statusP=["待支付","已发货","待收货","代发货","已关闭","已完成"]

// 定义数据类型
let {data} = Mock.mock({
  // 20条数据
  "data|150": [{
    // 商品Id
    "goodsId|+1": 100,
    // 实际金额
    "actualMoney|30-500": 30,
    // 快递金额
    "courierMoney|30-500": 30,
    // 收货人
    "name":"@ctitle(3)",
    //商品地址
    "goodsAddress": "@county(true)",
    // 支付方式
    "methodPay|1": methodP,
    // 状态
    "tag|1":statusP,
    // 操作
    
  }]
})



class ProductServer{
  getData({page,size}){
    return new Promise((resolve)=>{
      // 分页截取
      const result=data.slice((page-1)*size,page*size)
      resolve({
        status:0,
        // result:["1","2","3"],
        result:result,
        count:data.length,
      })
    })
  }
  removeData({goodsId}){
    return new Promise((resolve)=>{
      data = data.filter((item)=>item.goodsId !== goodsId)
      resolve({
        status:0,
        msg:"删除成功"
      })
    });
  }
}

const product=new ProductServer;
export default product;